import 'package:love_app/common/su_dio.dart';
import 'package:love_app/config/path_url.dart';
import 'package:love_app/enum/sex.dart';
import 'package:love_app/model/response_model.dart';
import 'package:love_app/service/base_api.dart';

class RegisterApi extends BaseApi{
  Future<bool> register(String phone, String phoneCode, String password, Sex sex)async{
    Map postData= {
      'phone': phone,
      'code': phoneCode,
      'sex':getSex(sex),
      'password': password,
    };
    String path = PathUrl.basePath('register');
    ResponseModel model = await SuDio().postRequest(path,data: postData);
    return isSuccess(model.response.data);
  }

  // 获取性别
  int getSex(Sex sex){
    // int sexData;
    int sexData  = sex == Sex.boy ? 1 : 2;
    return sexData;
  }

  // 重置密码
  Future<bool> forgetPassword(String phone, String phoneCode, String password)async{
    Map postData= {
      'phone': phone,
      'code': phoneCode,
      'password': password,
    };

    String path = PathUrl.basePath('forgetPassword');
    ResponseModel model = await SuDio().postRequest(path,data: postData);
    return isSuccess(model.response.data);
  }
}